<?php


class ConnectionManager {
    
    /**
     * @var      array
     */
    protected static $db = array();
    
    /**
     * @param    string $name    
     * @return   BaseDriver
     */
    static public function getConn($name = "default") {
        if (!in_array($name, array_keys(self::$db))) {
            self::$db[$name] = self::loadDatasource(DATABASE_CONFIG::$$name);
        }
        return self::$db[$name];
    }
    
    /**
     * @param    array $conn    
     * @return   BaseDriver
     */
    static protected function loadDatasource($config) {
        $driver = $config['driver'];
        return new $driver($config);
    }
}

?>